
<template>
    <div class="pushRecordDetail">
    	<el-breadcrumb separator="/" class="bread-title" >
    		<el-breadcrumb-item >配置中心</el-breadcrumb-item>
    		<el-breadcrumb-item>接口配置</el-breadcrumb-item>
    	    <el-breadcrumb-item :to="{ path: '/pushPaymentRecord',query:{issend:true}}">付款记录推送</el-breadcrumb-item>
    	    <el-breadcrumb-item>推送记录详情</el-breadcrumb-item>
    	</el-breadcrumb>
		<div style="margin-bottom:20px"><span>推荐客户id：{{crmCid}}</span><span style="margin-left: 30px">房源id：{{crmRoomGuid}}</span><span style="margin-left: 30px">佣金支付方式:{{payWay==1?'好生活资金池支付':'好生活垫付'}}</span></div>
		<el-table :data="tableData" border style="width: 100%">
			<el-table-column type="index" label="序号" width="50" align="center" fixed></el-table-column>
			<el-table-column label="成交价(元)" prop="dealPrice" align="center" :formatter="initCase"></el-table-column>
			<el-table-column label="佣金标准" prop="commissionRule" align="center"></el-table-column>
			<el-table-column label="应结佣金（元）" prop="amountPay" align="center" :formatter="initCase"></el-table-column>
			<el-table-column label="已结佣金（元）" prop="alreadyPay" align="center" :formatter="initCase"></el-table-column>
			<el-table-column label="提交申请时间1" prop="applyTimeFirst" align="center" :formatter="initTimer"></el-table-column>
			<el-table-column label="付款时间1" prop="alreadyTimeFirst" align="center" :formatter="initTimer"></el-table-column>
			<el-table-column label="提交申请时间2" prop="applyTimeSecond" align="center" :formatter="initTimer"></el-table-column>
			<el-table-column label="付款时间2" prop="alreadyTimeSecond" align="center" :formatter="initTimer"></el-table-column>
			<el-table-column label="推送时间" prop="pushTime" align="center" :formatter="initTimer"></el-table-column>
			<el-table-column label="推送状态" prop="pushStatus" align="center" width="80" :formatter="initpushStatus"></el-table-column>
			<el-table-column align="center" label="操作" width="100"  fixed='right'>
				<template slot-scope='scope'>
					<el-button type="text" :disabled="scope.row.pushStatus == 1" @click="pushhander(scope.row)">重新推送</el-button>
				</template>
			</el-table-column>
		</el-table>
		<div class="pagebar">
		  <el-pagination
		    background
		    layout="total, sizes, prev, pager, next"
		    :current-page.sync="pageNum"
		    :page-sizes="[10, 20, 30, 40]"
		    :page-size="pageSize"
		    @size-change="handleSizeChange"
		    @current-change="handleCurrentChange"
		    :total="totalSize">
		  </el-pagination>
		</div>
    </div>
</template>

<script>
import api from "@/api/apiPath"
import utils from "@/common/utils.js"

export default {
    name:"pushRecordDetail",
    data() {
        return {
            tableData:[],
            pageSize:10,
            pageNum:1,
            totalSize:0,
            crmCid: this.$route.query.crmCid,
            crmRoomGuid:this.$route.query.crmRoomGuid,
            payWay:this.$route.query.payWay
        }
    },
    created() {
        this.getlist()
    },
    methods: {
        initCase(row, column, cellValue, index){
           return cellValue? utils.formatMoney(cellValue): "0.00"            
        },
        initTimer(row, column, cellValue, index){
            if (!cellValue)  return
            return utils.getTimeString(cellValue)
        },
        initpushStatus(row, column, cellValue, index){
            if (!cellValue)  return
            if (cellValue == 1) {
                return '成功'
            }else{
                return '失败'
            }
        },
    	handleCurrentChange(){
    		this.getlist()
    	},
    	handleSizeChange(val){
            this.ruleForm.pageSize = val
            this.getlist();
    	},
    	getlist(){
            this.$axios.post('/forcrm/commission/pay/selectListById',{crmCid:this.crmCid,crmRoomGuid:this.crmRoomGuid}).then((res)=>{
                this.tableData = res.list
                this.totalSize = res.total
            })
    	},
    	pushhander(val){
            let temparr = [{crmCid:val.crmCid,crmRoomGuid:val.crmRoomGuid}]
            this.$confirm('是否重新推送?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).then(() => {
                this.$axios.post('/forcrm/commission/pay/pushToCrm',temparr).then(res=>{
                    this.$message({
                        type: "success",
                        message: "推送成功"
                    })
                    this.getlist()
                })
            }).catch(() => {
              this.$message({
                type: 'info',
                message: '已取消'
              });          
            });
    	},
    }
}
</script>
<style lang="stylus" scoped>
    .test2 {
        
    }
</style>